<template>
	<view class="pageBox">
		<view class="main">
			<view class="logistics">
				<view class="top">
					快递公司：{{cn}}
				</view>
				<view class="bom flex-between">
					<view class="logisticsNo">
						物流单号：{{postNo}}
					</view>
					<button :plain="true" class="copyBtn" @click="copy(postNo)">复制单号</button>
				</view>
			</view>

			<view class="list" v-if="type == 0">
				<view class="listTitle">
					物流跟踪
				</view>

				<view class="listItem" v-for="(item,index) in dataList" :key="index">
					<view class="listItemLeft flex-center">
						<view class="shuXian" v-if="index != 0 && dataList.length">

						</view>
						<image class="choosed" src="http://www.bobei.shop/static/login/choosed.png"></image>
						<view class="shuXian" v-if="index != dataList.length - 1">

						</view>
					</view>
					<view class="listItemRight">
						<view class="text">
							{{ item.context }}
						</view>
						<view class="text">
							{{ item.ftime }}
						</view>
					</view>
				</view>
			</view>
			<view class="list" v-if="type != 0">
				<view class="listTitle">
					物流跟踪
				</view>

				<view class="listItem" v-for="(item,index) in traces" :key="index">
					<view class="listItemLeft flex-center">
						<view class="shuXian" v-if="index != 0 && traces.length">

						</view>
						<image class="choosed" src="http://www.bobei.shop/static/login/choosed.png"></image>
						<view class="shuXian" v-if="index != traces.length - 1">

						</view>
					</view>
					<view class="listItemRight">
						<view class="text">
							{{ item.AcceptStation }}
						</view>
						<view class="text">
							{{ item.AcceptTime }}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				postNo: '',
				cn: '',
				com: '',
				orderId: '',
				type: "", // 0是平台的商品
				dataList: [],
				traces: [],
			}
		},
		onLoad(e) {
			this.cn = e.cn,
				this.postNo = e.postNo
			this.com = e.post
			this.orderId = e.orderId
			this.getPost()
		},
		methods: {
			getPost() {
				this.$post({
					url: "/portal/Shop",
					module: "Order",
					interface: 2000,
					data: {
						com: this.com,
						num: this.postNo,
						orderId: this.orderId
					}
				}).then((res) => {
					this.type = res.type;
					// console.log(res, this.type);
					if (res.type == 0) {
						this.dataList = res.data;
					} else {
						res.Traces.forEach((item) => {
							this.traces.unshift(item);
						})
					}
				})
			},
			copy(code) {
				// #ifdef H5
				this.$setClipboardData({
					data: code,
					success: function() {
						uni.showToast({
							title: '复制成功',
							icon: "none",
							duration: 1500,
						})
					}
				})
				// #endif
				// #ifndef H5
				uni.setClipboardData({
					data: code,
					success: function() {
						uni.showToast({
							title: '复制成功',
							icon: "none",
							duration: 1500,
						})
					}
				});
				// #endif
			}

		},
	}
</script>

<style scoped lang="scss">
	.pageBox {
		width: 100%;
		min-height: calc(100vh - var(--window-top));
		background-color: #F5F5F5;

		.main {
			padding: 32rpx;

			.logistics {
				padding: 32rpx;
				border-radius: 16rpx;
				background-color: #ffffff;

				.top {
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #000000;
					line-height: 44rpx;
				}

				.bom {
					margin-top: 20rpx;

					.logisticsNo {
						font-size: 28rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #000000;
						line-height: 44rpx;
					}

					.copyBtn {
						padding: 0;
						margin: 0;
						font-size: 28rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #F2615F;
						width: 168rpx;
						height: 60rpx;
						border-radius: 52rpx;
						border: 2rpx solid #F2615F;
					}
				}
			}

			.list {
				margin-top: 30rpx;
				padding: 32rpx;
				border-radius: 16rpx;
				background-color: #ffffff;

				.listTitle {
					font-size: 30rpx;
					font-family: PingFangSC-Semibold, PingFang SC;
					font-weight: 600;
					color: #333333;
					border-bottom: 1px solid #E3E3E3;
					padding-bottom: 30rpx;
					margin-bottom: 30rpx;
				}

				.listItem {
					padding-left: 109rpx;
					position: relative;

					.listItemLeft {
						width: 109rpx;
						height: 100%;
						position: absolute;
						left: 0;
						top: 50%;
						transform: translate(0, -50%);
						flex-direction: column;


						.choosed {
							width: 40rpx;
							height: 40rpx;
						}

						.shuXian {
							color: transparent;
							width: 4rpx;
							height: 100%;
							flex: 1;
							background-color: #E3E3E3;
						}
					}

					.listItemRight {
						flex: 1;
						padding: 10rpx;

						.text {
							font-size: 28rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #333333;
						}

					}
				}
			}
		}
	}
</style>
